package com.yx.controller;

import com.yx.annotation.SystemLog;
import com.yx.domain.ResponseResult;
import com.yx.domain.entity.Article;
import com.yx.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author 86159
 */
@RestController
@RequestMapping("/article")
public class ArticleController {
    @Autowired
    private ArticleService articleService;
    @GetMapping("/hotArticleList")
    @SystemLog(businessName = "查询热门文章")
    public ResponseResult hotArticleList(){
//        查询热门文章列表,封装成ResponseResult返回
        ResponseResult result=articleService.hotArticleList();

        return result;
    }
    @GetMapping("/articleList")
    @SystemLog(businessName = "查询文章列表")
    public ResponseResult articleList(Integer pageNum,Integer pageSize,Long categoryId){
        System.out.println(categoryId.getClass().getName().toString());
        return articleService.articleList(pageNum,pageSize,categoryId);
    }
    @GetMapping("/{id}")
    @SystemLog(businessName = "查询某一文章")
    public ResponseResult getArticleDetail(@PathVariable("id") Long id){
        return articleService.getArticleDetail(id);
    }

    @PutMapping("/updateViewCount/{id}")
    @SystemLog(businessName = "更新文章浏览量")
    public ResponseResult updateViewCount(@PathVariable("id") Long id){
        return articleService.updateViewCount(id);
    }
}
